<?php


class Core_Db
{

    protected static $_instance = null;

    private $_db = null;

    protected function  __construct()
    {}
    
    public static function instance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }
        return self::$_instance;
    }


    public function set_db(IDb $db)
    {
        $this->_db = $db;
    }
    
    public function connect()
    {
        if (null === $this->_db) {
            return false;
        } else {
            return $this->_db->connect();
        }
    }

    public function close()
    {
        if (null === $this->_db) {
            return false;
        } else {
            return $this->_db->close();
        }
    }

    public function query($query)
    {
        if (null === $this->_db) {
            return false;
        } else {
            return $this->_db->query($query);
        }
    }

}

?>
